
import 'package:flutter/material.dart';

class FormPage extends StatefulWidget{
  @override
  State<StatefulWidget> createState() {
    return new _FormPageState();
  }
}

class _FormPageState extends State<FormPage>{

  bool _switchSelected = false;
  bool _checkboxSelected = false;
  TextEditingController _unameController = TextEditingController();
  String _input = '';

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      appBar: new AppBar(
        title: Text('表单'),
      ),
      body: ListView(
        children: [
          Container(
            child: Flex(
              mainAxisAlignment: MainAxisAlignment.center,
              crossAxisAlignment: CrossAxisAlignment.center,
              direction: Axis.vertical,
              children: [
                Row(
                  children: [
                    Padding(
                      padding:const EdgeInsets.symmetric(
                        horizontal: 20
                      ),
                      child: Text('开关'),
                    ),
                    Switch(
                      value: this._switchSelected,
                      onChanged: (value){
                        setState(() {
                          this._switchSelected = value;
                        });
                      },
                    )
                  ],
                ),
                Row(
                  children: [
                    Padding(
                      padding:const EdgeInsets.symmetric(
                          horizontal: 20
                      ),
                      child: Text('复选框'),
                    ),
                    Checkbox(
                      value: this._checkboxSelected,
                      onChanged: (value){
                        setState(() {
                          this._checkboxSelected = value;
                        });
                      },
                    )
                  ],
                ),
                Padding(
                  padding:const EdgeInsets.symmetric(horizontal: 14),
                  child: Column(
                    children: <Widget>[
                      Padding(
                        padding:const EdgeInsets.symmetric(
                            horizontal: 20
                        ),
                        child: Text('输入框'),
                      ),
                      TextField(
                        autofocus: true,
                        decoration: InputDecoration(
                            labelText: "用户名",
                            hintText: "用户名或邮箱",
                            prefixIcon: Icon(Icons.person)
                        ),
                      ),
                      Container(
                        child:  TextField(
                          controller: _unameController,
                          decoration: InputDecoration(
                              labelText: "密码",
                              hintText: "您的登录密码",
                              prefixIcon: Icon(Icons.lock)
                          ),
                          obscureText: true,
                        ),
                      )
                    ],
                  ),
                )
              ],
            ),
          )
        ],
      ),
    );
  }
}